import request from '@/utils/request'

export function list(token,data){
  return request({
    url: 'cms/store_bank/get_select',
    method: 'post',
    params: {token},
    data
  })
}


// del(删除银行)
export function del(token, customer_store_identification_id){
  return request({
    url: 'cms/store_bank/delete',
    method: 'post',
    params: {token},
    data:{customer_store_identification_id}
  })
}

// add(增加银行)
export function add(token, data){
  return request({
    url: 'cms/store_bank/add',
    method: 'post',
    params: {token},
    data
  })
}

//
export function edit(token, data){
  return request({
    url: 'cms/store_bank/change',
    method: 'post',
    params: {token},
    data
  })
}


export class BankTransform{

  // 传递进来的数据
  constructor(bank_data){
    this.result = []
    this.bank_data = bank_data
  }

  // 转换方法
  transForm(){
    for (let[index,bank] of this.bank_data.entries()) {
      this.result[index] = {}
      this.result[index].value = bank.bank_id
      this.result[index].label = bank.name
      this.result[index].children = []
      for(let [indexy, branch] of bank.all_name.entries()){
        this.result[index].children[indexy] = {}
        this.result[index].children[indexy].value = branch.bank_branch_id
        this.result[index].children[indexy].label = branch.name
      }
    }
    return this.result
  }
}
